#include<iostream>
using namespace std;
void Test()
{
	int* p1 = (int*)malloc(sizeof(int));
	free(p1);

	int* p2 = (int*)calloc(4, sizeof(int));
	int* p3 = (int*)realloc(p2, sizeof(int) * 10);

	free(p3);
}
void Test2()
{
	//Test();
	int* ptr1 = new int;
	int* ptr2 = new int(10);
	int* ptr3 = new int[3];
	int* ptr4 = new int[10]{1};
	int* ptr5 = new int[10]{1, 2, 3};

	delete ptr1;
	delete ptr2;
	delete[] ptr3;
	delete[] ptr4;
	delete[] ptr5;
}

class A
{
public:
	A(int a = 0)
		:_a(a)
	{
		cout << "A()" << this << endl;
	}

	~A()
	{
		cout << "~A():" << this << endl;
	}
private:
	int _a;
};

void Test3()
{
	//A* p1 = (A*)malloc(sizeof(A));
	//A* p2 = new A(1);

	//free(p1);
	//delete p2;

	A* p3 = new A[10];

	delete[] p3;
}

struct ListNode
{
	ListNode* _next;
	int _val;

	ListNode(int val)
		:_next(nullptr)
		,_val(val)
	{}
};

void func()
{
	ListNode* n1 = new ListNode(1);
	ListNode* n2 = new ListNode(2);
	ListNode* n3 = new ListNode(3);

	n1->_next = n2;
	n2->_next = n3;

	delete n1;
	delete n2;
	delete n3;
}

